package com.chengma.controller;

import java.util.List;

import com.chengma.common.AjaxResult;
import com.chengma.common.BaseController;
import com.chengma.common.TableDataInfo;
import com.chengma.domain.TbQuestion;
import com.chengma.service.ITbQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 问题Controller
 *
 * @author tck
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/system/question")
public class TbQuestionController extends BaseController {
    @Autowired
    private ITbQuestionService tbQuestionService;

    /**
     * 查询问题列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody TbQuestion tbQuestion) {
        List<TbQuestion> list = tbQuestionService.selectTbQuestionList(tbQuestion);
        return getDataTable(list);
    }

    /**
     * 获取问题详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tbQuestionService.selectTbQuestionById(id));
    }

    /**
     * 新增问题
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbQuestion tbQuestion) {
        return toAjax(tbQuestionService.insertTbQuestion(tbQuestion));
    }

    /**
     * 修改问题
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TbQuestion tbQuestion) {
        return toAjax(tbQuestionService.updateTbQuestion(tbQuestion));
    }

    /**
     * 删除问题
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tbQuestionService.deleteTbQuestionByIds(ids));
    }
}
